package com.yonyou.cyxdms.basedata.service.controller.configure;

import com.yonyou.cyx.framework.controller.base.BaseController;
import com.yonyou.cyxdms.basedata.client.domains.vo.PackageCacheVO;
import com.yonyou.cyxdms.basedata.service.service.configure.PackageService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 配置
 *
 * @author renwd
 * @since 2018/12/11
 */

@RestController
@RequestMapping("/package")
public class PackageController extends BaseController {

    @Autowired
    private PackageService packageService;

    /**
     * 按条件查询配置信息
     *
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.basedata.client.domains.DTO.basedata.PackageCacheVO>
     * @author renwd
     * @since 2018/12/11
     */
    @GetMapping(value="/queryPackageByCondition")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public List<PackageCacheVO> queryPackageByCondition(@RequestParam Map<String, Object> queryParam) {
        return packageService.queryPackageByCondition(queryParam);
    }

    /**
     * 根据车型Id查询车辆配置信息
     *
     * @param modelId
     * @return java.util.List<com.yonyou.cyxdms.basedata.client.domains.DTO.basedata.PackageCacheVO>
     * @author guorp
     * @since 2018/12/13
     */
    @GetMapping("/getPackageByModelId")
    public List<PackageCacheVO> getPackageByModelId(@RequestParam Long modelId){
        return  packageService.getPackageByModelId(modelId);
    }

    /**
     * JK获取id与code映射数据
     *
     * @param:
     * @return:
     * @auther: tanjie
     * @since: 2019/9/10
     */
    @GetMapping("/queryPackageMapping")
    public Map<Long, String> queryPackageMapping(@RequestParam("appId") String appId) {
        return packageService.queryPackageMapping(appId);
    }

    /**
     * 获取所有配置
     *
     * @param:
     * @return:
     * @auther: tanjie
     * @since: 2019/11/4
     */
    @GetMapping("/getAllPackageByAppId")
    public List<PackageCacheVO> getAllPackageByAppId(@RequestParam("appId") String appId) {
        return this.packageService.getAllPackageByAppId(appId);
    }
}
